<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <style>
        #box{
            width: 350px;
            height: 150px;
            margin: 200px auto;
        }
        body{
            background: url("${pageContext.request.contextPath}/img/timg.jpg") no-repeat 0 0 /2000px 800px;
        }
    </style>
    <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/layui/layui.js" charset="utf-8"></script>
    <style>
        .layui-input{
            width: 200px;
        }
        .max{
            margin: auto;
            margin-top: 170px;
            width: 400px;
        }
    </style>--%>
</head>
<body>
<div id="box">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-inline">
                <input type="text" name="staffId" required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-filter="dengLu" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath}/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','jquery','layer'], function(){
        var form = layui.form;
        var $ = layui.jquery;
        var layer = layui.layer;

        form.on('submit(dengLu)', function(data){
            $.ajax({
                type:'post',
                url:'staff/login',
                dataType:'json',//预期的后台数据类型
                data:{"staffId":data.field.staffId,"password":data.field.password},//当前表单的所有数据
                success:function (data) {
                    if (data.code == "1002"){
                        layer.msg(data.msg, {icon: 5});
                    }else if (data.code == "1003"){
                        layer.msg(data.msg, {icon: 5});
                    }else if (data.code == "1004"){
                        layer.msg(data.msg, {icon: 5});
                    }else {
                        /*alert(111);*/
                        window.location.href = "menu/getAllMenus";
                    }
                    //alert(data);
                }
                /*success:function (data) {
                    alert(111);
                }*/
            })
            return false;
        });
    });
</script>
<script language="JavaScript" type="text/javascript">
    if (window != top)
        top.location.href=location.href;

</script>
</body>

<%--<body>
<div class="layui-form max"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" id="username" placeholder="请输入用户名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" id="pword" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button id="sub" class="layui-btn" lay-submit lay-filter="*">登录</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->
</div>
<script>
    /*$(".layui-btn").get({

    })*/
    layui.use(['element','layer'], function(){
        var $ = layui.jquery,
            element = layui.element;
        var layer = layui.layer;
        $("#sub").click(function (){
            var staffId =  $("#username").val();
            var password =  $("#pword").val();
            $.post(
                "${pageContext.request.contextPath}/staff/login",
                {staffId,password},
                function (bakedata){
                    /*if (bakedata.code==300 ){
                        layer.msg(bakedata.msg, {icon: 5});
                    }else{
                        //window.location.href = "homePage.jsp";
                        //表示登录成功，本来应该要直接跳转到管理系统首页，现在需要先去查询当前用户对应的权限
                        window.location.href = "menu/getAllMenuByRId";
                    }*/
                    alert("111");
                })
        })
    });
</script>
</body>--%>

</html>
